<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
#use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        if (Schema::hasTable('admin_operate_logs')) return;
        Schema::create('admin_operate_logs', function (Blueprint $table) {
            $table->id();
            $table->string('log_no', 50)->default('')->unique()->comment('日志编码');
            $table->string('module_name')->default('')->comment('系统模块名称');
            $table->text('content')->comment('操作内容');
            $table->unsignedInteger('creator_id')->default(0)->comment('操作人ID');
            $table->string('creator_name')->default('')->comment('操作人');
            $table->string('ip_address', 50)->default('')->comment('ip地址');
            $table->dateTime('created_at')->default(\DB::raw('CURRENT_TIMESTAMP'));
            $table->timestamp('updated_at')->default(\DB::raw('CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP'));
        });
        DB::statement("ALTER TABLE `admin_operate_logs` COMMENT '后台操作日志'");
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        if (!is_production()) Schema::dropIfExists('admin_operate_logs');
    }
};
